#ifndef LINI_BUILDER_H
#define LINI_BUILDER_H

#include "lini_typedef.h"
#include <stdlib.h>


struct _LiniBuilder;
typedef struct _LiniBuilder LiniBuilder;


typedef void (*LiniBuilderOnGroup)(LiniBuilder *thiz, char *group);
typedef void (*LiniBuilderOnKeyValue)(LiniBuilder *thiz, char *key, char *value);
typedef void (*LiniBuilderOnComment)(LiniBuilder *thiz, char *comment);
typedef void (*LiniBuilderDestroyFunc)(LiniBuilder *thiz);

struct _LiniBuilder
{
	LiniBuilderOnGroup on_group;
	LiniBuilderOnKeyValue on_key_value;
	LiniBuilderOnComment on_comment;
	LiniBuilderDestroyFunc destroy;
    unsigned char ref_count;
	char* priv;
};

static inline void lini_builder_on_group(LiniBuilder *thiz, char *group)
{
	if(thiz != NULL && thiz->on_group != NULL){
		thiz->on_group(thiz, group);
	}
	return;
}

static inline void lini_builder_on_comment(LiniBuilder *thiz, char *comment)
{
	if(thiz && comment){
		thiz->on_comment(thiz,  comment);
	}

	return;
}

static inline void lini_builder_on_key_value(LiniBuilder *thiz, char *key, char *value)
{
	if(thiz	!= NULL && key != NULL){	
		thiz->on_key_value(thiz, key, value);
	}

	return;
}

static inline void lini_builder_destroy(LiniBuilder *thiz)
{
	if(thiz != NULL  && thiz->destroy != NULL){
		thiz->destroy(thiz);
	}

	return;
}


#endif 


